#pragma once

#include "Misc/CommonMacros.h"

#include "Math/Coordinate.h"
#include "Math/Rect.h"
#include "Math/Vec3.h"
#include "Math/Vec2.h"
#include "Math/IntPoint.h"
#include "Math/Quat.h"
#include "Math/Color.h"
#include "Math/Matrix3x3.h"
#include "Math/Matrix4x4.h"

class WHENGINE_API CMath : public CMathBase
{
public:
    static SVec3 RadianToDegree(const SVec3& InRadians)
    {
        return InRadians *_180DevidePi;
    }
                 
    static SVec3 DegreeToRadian(const SVec3& InDegree)
    {
        return InDegree * PiDevide180;
    }

    static SVec3 ToVec3(const SVec4& InVec4)
    {
        return SVec3(InVec4.X,InVec4.Y,InVec4.Z);
    }


    //投影点到平面
    //InPoint 点
    //InPlaneNormal 平面法线
    //InPlanePoint 平面上一点
    //return 投影点
    static SVec3 ProjectPointToPlane(
        const SVec3& InPoint
        ,const SVec3& InPlaneNormal
        ,const SVec3& InPlanePoint);

    //求两直线的交点
    //InLine1Point1 直线1上一点
    //InLine1Direction 直线1方向
    //InLine2Point2 直线2上一点
    //InLine2Direction 直线2方向
    //OutIntersectionPoint 交点
    //返回值 是否相交
    static bool LineLineIntersection(
        const SVec3& InLine1Point1
        ,const SVec3& InLine1Direction
        ,const SVec3& InLine2Point2
        ,const SVec3& InLine2Direction
        ,SVec3& OutIntersectionPoint);

    //视口坐标转换到世界坐标
    //InViewportPos 视口坐标
    //InViewportWidth 视口宽度
    //InViewportHeight 视口高度
    //InProjectionMatrix 投影矩阵
    //InViewMatrix 视图矩阵
    //OutWorldDirection 世界坐标系下鼠标射线方向
    static SVec3 DeprojectViewportToScene(
        const SVec2& InViewportPos
        ,float InViewportWidth
        ,float InViewportHeight
        ,const SMatrix4x4& InProjectionMatrix
        ,const SMatrix4x4& InViewMatrix
        ,SVec3& OutWorldDirection);
    

    //世界坐标转换到视口坐标
    //InWorldPos 世界坐标
    //InViewportWidth 视口宽度
    //InViewportHeight 视口高度
    //InProjectionMatrix 投影矩阵
    //InViewMatrix 视图矩阵
    static SVec2 ProjectSceneToViewport(
        const SVec3& InWorldPos
        ,float InViewportWidth
        ,float InViewportHeight
        ,const SMatrix4x4& InProjectionMatrix
        ,const SMatrix4x4& InViewMatrix);
};
